(function(){

	nsbase.views.mapGameInfo = new  MapGameInfoFunc();

	function MapGameInfoFunc() {
		var _self = this;

		_self.init = init;

		var $mapContent = $(".mapContent");

		var gameUrls = nsbase.config.actionUrl.game,
			utilities = nsbase.utility;

		function init (points) {
      		$(".nav_menu li.Online").addClass("selected");
			userPhoto(1,points);
		}

		function bindHandlers() {
			
		}

		function userPhoto2 (index,points) {
			index = !index?1:index;
			var length = (points&&points.length>0)?points.length:1;
			if(index > length) return;

			var r = index%2;
			var $foot1 = $('<img src="../static/images/f' + (r + 1) + '.png" style="display:none;position:absolute"/>');
			$(".mapContent").append($foot1);
			var left = 130 + points[index-1].point_x;
			var top = 75 + points[index-1].point_y;
			
			index++;
			$foot1.css({"left":left,"top":top});
			$foot1.fadeIn(1000,function(){
				userPhoto2(index,points);
			});
		}

		function userPhoto (index,points) {
			index = !index?1:index;
			var length = (points&&points.length>0)?points.length:1;
			if(index > length) return;

			var point = points[index-1];
			var left = 130 + point.point_x;
			var top = 80 + point.point_y;
			var contentTmp = '<div class="scenic">\
					              <div class="title">{0}</div>\
					              <div class="content">{1}</div>\
					            </div>';
			var photoClone = $('<img src="../static/images/icon_coord.png" style="position:absolute;"/>') ;
			if(index == length){
				photoClone = $('<img src="../static/images/et_head.png" style="position:absolute;"/>') ;
				left = left - 40;
				top = top - 40;
			}
			if(point.point_name){
				photoClone.attr("title","");
				photoClone.tooltip({
					content:function () {
						var content = utilities.stringFormat(contentTmp,point.point_name,point.point_content);
						return content;
					}
				});
			}

			$mapContent.append(photoClone);
			
			index++;
			photoClone.css({"top":0,"left":left});
			photoClone.animate({"top":top},function(){
				userPhoto(index,points);
				photoClone.animate({"top":top-30},100,function(){
					photoClone.animate({"top":top-20},100);
				});
			});
		}
	}
	
})();